/*
 ============================================================================
 Name		: TheWebAppView.h
 Author	  : Vitaly Yevtushenko
 Copyright   : Licensed under GPL V2
 Description : Declares view class for application.
 ============================================================================
 */

#ifndef __THEWEBAPPVIEW_h__
#define __THEWEBAPPVIEW_h__

// INCLUDES
#include <coecntrl.h>

#include "WebData.h"

// CLASS DECLARATION
class CTheWebAppView : public CCoeControl
	{
public:
	// New methods

	/**
	 * NewL.
	 * Two-phased constructor.
	 * Create a CTheWebAppView object, which will draw itself to aRect.
	 * @param aRect The rectangle this view will be drawn to.
	 * @return a pointer to the created instance of CTheWebAppView.
	 */
	static CTheWebAppView* NewL(const TRect& aRect);

	/**
	 * NewLC.
	 * Two-phased constructor.
	 * Create a CTheWebAppView object, which will draw itself
	 * to aRect.
	 * @param aRect Rectangle this view will be drawn to.
	 * @return A pointer to the created instance of CTheWebAppView.
	 */
	static CTheWebAppView* NewLC(const TRect& aRect);

	/**
	 * ~CTheWebAppView
	 * Virtual Destructor.
	 */
	virtual ~CTheWebAppView();

public:
	// Functions from base classes

	/**
	 * From CCoeControl, Draw
	 * Draw this CTheWebAppView to the screen.
	 * @param aRect the rectangle of this view that needs updating
	 */
	void Draw(const TRect& aRect) const;
	
	/**
	 * Draw main menu on screen.
	 * @param aRect the rectangle of this view that needs updating
	 */
	void DrawMainMenu(CWindowGc& gc, const TRect& aRect) const;

	/**
	 * Draw gameplay on screen.
	 * @param aRect the rectangle of this view that needs updating
	 */
	void DrawGame(CWindowGc& gc, const TRect& aRect) const;

	/**
	 * Draw game editor on screen.
	 * @param aRect the rectangle of this view that needs updating
	 */
	void DrawEditor(CWindowGc& gc, const TRect& aRect) const;

	/**
	 * From CoeControl, SizeChanged.
	 * Called by framework when the view size is changed.
	 */
	virtual void SizeChanged();

	/**
	 * From CoeControl, HandlePointerEventL.
	 * Called by framework when a pointer touch event occurs.
	 * Note: although this method is compatible with earlier SDKs, 
	 * it will not be called in SDKs without Touch support.
	 * @param aPointerEvent the information about this event
	 */
	virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
	
	/**
	 * Handles pointer events in Main Menu
	 * @param aPointerEvent the information about this event
	 */
	void HandleMainMenuPointerEventL(const TPointerEvent& aPointerEvent);
	
	/**
	 * Handles pointer events in Game
	 * @param aPointerEvent the information about this event
	 */
	void HandleGamePointerEventL(const TPointerEvent& aPointerEvent);
	
	/**
	 * Handles pointer events in Editor
	 * @param aPointerEvent the information about this event
	 */
	void HandleEditorPointerEventL(const TPointerEvent& aPointerEvent);
	
	/**
	 * Game states
	 */
	enum TState 
		{
		EMainMenu,
		EGame,
		EEditor
		};

private:
	// Constructors

	/**
	 * ConstructL
	 * 2nd phase constructor.
	 * Perform the second phase construction of a
	 * CTheWebAppView object.
	 * @param aRect The rectangle this view will be drawn to.
	 */
	void ConstructL(const TRect& aRect);

	/**
	 * CTheWebAppView.
	 * C++ default constructor.
	 */
	CTheWebAppView();
	
	/**
	 * Set the reactangles of on-screen buttons
	 */
	void SetRects();
	
	/**
	 * Web Data
	 */
	CWebData *iWebData;
	
	/**
	 * Dragging data
	 */
	TBool iDragging;
	
	/**
	 * Current game state
	 */
	TState iState;
	
	/**
	 * text labels
	 */
	HBufC *iCaption, *iExit, *iPlay, *iEdit, *iAbout;
	
	/**
	 * label font
	 */
	CFont *iLabelFont;
	
	/**
	 * Rects for buttons in Main Menu
	 */
	TRect iRtMenuPlay, iRtMenuEdit, iRtMenuExit, iRtMenuAbout;

	};

#endif // __THEWEBAPPVIEW_h__
// End of File
